import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/monster/monsterRocProjectSetup/list',
  save='/monster/monsterRocProjectSetup/add',
  edit='/monster/monsterRocProjectSetup/edit',
  deleteOne = '/monster/monsterRocProjectSetup/delete',
  deleteBatch = '/monster/monsterRocProjectSetup/deleteBatch',
  importExcel = '/monster/monsterRocProjectSetup/importExcel',
  exportXls = '/monster/monsterRocProjectSetup/exportXls',
  // RC项目详情
  rcDetail= '/monster/monsterRocProjectSetup/queryById',
  monsterSetupApplyDetail= '/monster/monsterSetupApply/queryById',
  monsterSubmitApplys= '/monster/monsterSubmitApply/queryById',
  monsterOffeiceApplys= '/monster/monsterOfficeApply/queryById',

  getConfig= '/monster/monsterConfig/queryConfig',
  getLog= '/monster/monsterSetupApply/queryListByProjectId',
  apply= '/monster/monsterSetupApply/add',
  // 人力审核
  proApplyInfo= '/monster/monsterHrProjectSetup/queryById',
  proApply= '/monster/monsterSetupApply/projectSetupApply',
  hrApply= '/monster/monsterHrCostSubmit/add',
  submitDetail='/monster/monsterSupplierCostSubmit/queryById',
  tripInfo='/monster/monsterTripCostSubmit/queryById',
  hrInfo= '/monster/monsterHrCostSubmit/queryById',
  submitApply= '/monster/monsterSubmitApply/add',
  staffList= '/monster/monsterHrCostSubmit/submitStaffList',
  otherInfo='/monster/monsterOtherCostSubmit/queryById',
  // 送审 通过，拒绝，待审核  1 通过 2 拒绝 3 待审核
  sendProjectSetupApply='/monster/monsterSetupApply/sendProjectSetupApply',

  closeProject='/monster/monsterRocProjectSetup/close',
  // ROC
  rocQueryById='/monster/monsterRocProjectSetup/queryById',
  // hr
  hrQueryById='/monster/monsterHrProjectSetup/queryById',
  //oop
  oopQueryById='/monster/monsterOopProjectSetup/queryById',
  // 提交审核记录
  getLogInfo='/monster/monsterSubmitApply/queryListByProjectId'
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.get({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.get({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}

export const apply = (params) => {
  return defHttp.post({url: Api.apply, params});
}

// ROC项目详情
export const getRocDetail = (params) =>
  defHttp.get({url: Api.rocQueryById, params});

// HR项目详情
export const getHrDetail = (params) =>
  defHttp.get({url: Api.hrQueryById, params});

// OOP项目详情
export const getOopDetail = (params) =>
  defHttp.get({url: Api.oopQueryById, params});

// 详情
export const monsterSetupApplyDetail = (params) =>
  defHttp.get({url: Api.monsterSetupApplyDetail, params});

export const monsterSubmitApplys = (params) =>
  defHttp.get({url: Api.monsterSubmitApplys, params});

export const monsterOfficeApplys = (params) =>
  defHttp.get({url: Api.monsterOffeiceApplys, params});
  // 获取配置
export const getRcConfig = () =>
defHttp.get({url: Api.getConfig});

// 记录
export const getRcLog = (params) =>
  defHttp.get({url: Api.getLog, params});

export const getLogInfo = (params) =>
  defHttp.get({url: Api.getLogInfo, params});

export const getProApplyInfo = (params) =>
  defHttp.get({url: Api.proApplyInfo, params});

export const proApply = (params) => {
  return defHttp.post({url: Api.proApply, params});
}
// 送审
export const sendProjectSetupApply = (params) => {
  return defHttp.post({url: Api.sendProjectSetupApply, params});
}
// 关闭项目
export const closeProject = (params) => {
  return defHttp.get({url: Api.closeProject, params});
}
export const hrApply = (params) => {
  return defHttp.post({url: Api.hrApply, params});
}

export const submitApply = (params) => {
  return defHttp.post({url: Api.submitApply, params});
}

// 详情
export const submitDetail = (params) =>
  defHttp.get({url: Api.submitDetail, params});

  // 详情
export const tripInfo = (params) =>
defHttp.get({url: Api.tripInfo, params});

export const hrInfo = (params) =>
defHttp.get({url: Api.hrInfo, params});

export const staffList = (params) =>
defHttp.get({url: Api.staffList, params});

export const otherInfo = (params) =>
defHttp.get({url: Api.otherInfo, params});

